package main

import (
	"flag"
	"fmt"
	"gitee.com/lyrlyrlyr/codegen/util/parseutil"
	"os"
)

////go:embed: template
//var embedTpl string
//
//func PrintTpl() {
//	fmt.Println(embedTpl)
//}

//go:generate codegen
func main() {
	//PrintTpl()
	var (
		modelName string
		pkgPath   string
		pkgName   string
		fileName  string
	)
	flag.StringVar(&modelName, "modelName", "", "输入对象名字")
	flag.StringVar(&pkgPath, "pkgPath", "", "输入包路径")
	flag.StringVar(&pkgName, "pkgName", "", "输入包名字")
	flag.StringVar(&fileName, "fileName", "", "请输入文件名字")
	flag.Parse()
	if pkgPath == "" {
		pkgPath = "./"
	}
	////flag.StringVar(&path,"path","","代码路径")
	//////flag.StringVar( &tabname,"tableName","","表名字")
	////flag.StringVar(&structName,"modelName","","结构体名字")
	//flag.Parse()
	//
	if modelName == "" || fileName == "" || pkgPath == "" {
		fmt.Printf("请输入模块名字 modelName=%v,pkgPath=%v, pkgName=%v,fileName=%v \n", modelName, pkgPath, pkgName, fileName)
		return
	}
	pwd, _ := os.Getwd()
	fmt.Println(pwd)
	os.MkdirAll(pkgPath, 0644)
	//fileName = pwd+"/"+fileName
	//if path == ""{
	//	path = pwd
	//}
	parseutil.ParseFileName(fileName, pkgPath, pkgName, modelName)

}
